//
//  BCMEditProductViewController.m
//  BCManagerVersion
//
//  Created by ZhaoXiang on 3/8/14.
//  Copyright (c) 2014 Jungle. All rights reserved.
//

#import "BCMEditProductViewController.h"
#import <SDWebImage/UIButton+WebCache.h>
#import <SDWebImage/UIImageView+WebCache.h>
@interface BCMEditProductViewController ()
@property (nonatomic, strong) NSArray* icons;
@end

@implementation BCMEditProductViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

#define ICON_WIDTH 100
#define ICON_GAP 10

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.titleTextField.text = self.product.title;
    self.messageTitleField.text = self.product.message;
    [self.navigationController setNavigationBarHidden:YES];
    [self.image setImageWithURL:[NSURL URLWithString:self.product.image] placeholderImage:nil];
    UITapGestureRecognizer *tapGr = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(stopEdit:)];
	[self.view addGestureRecognizer:tapGr];
}




- (void)stopEdit:(UITapGestureRecognizer *)gestureRecognizer {
	[self cancel:nil];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)cancel:(id)sender
{
    if (self.cancel) {
        self.cancel();
        self.cancel = nil;
    }
}


- (instancetype)initWithProduct:(ClientProdutModel*)product
                        success:(VoidBlock)success
                         cancel:(VoidBlock)cancel
{
    self = [self initWithNibName:@"BCMEditProductViewController" bundle:nil];
    if (self) {
        self.product = product;
        self.success = success;
        self.cancel = cancel;
    
    }
    return self;
}
@end
